<template>
  <a-layout-sider v-model:collapsed="collapsed" collapsible>
    <a-menu
      v-model:selectedKeys="selectedKeys"
      theme="dark"
      mode="inline"
      style="padding-top: 15px"
    >
      <a-menu-item key="1" @click="changeRouter('/index')">
        <DashboardOutlined />
        <span>首页</span>
      </a-menu-item>
      <a-sub-menu v-if="admin" key="sub1">
        <template #title>
          <span>
            <UsergroupAddOutlined />
            <span>权限</span>
          </span>
        </template>
        <a-menu-item key="27" @click="changeRouter('/storecheck')"
          ><EyeOutlined /><span>店铺审核</span></a-menu-item
        >
        <a-menu-item key="3" @click="changeRouter('/business')"
          ><UserAddOutlined /><span>店铺管理</span></a-menu-item
        >
        <a-menu-item key="4" @click="changeRouter('/user')"
          ><UserOutlined /><span>用户管理</span></a-menu-item
        >
        <a-menu-item key="33" @click="changeRouter('/online')"
          ><DesktopOutlined /><span>在线用户</span></a-menu-item
        >
      </a-sub-menu>
      <a-sub-menu v-if="!admin" key="sub2">
        <template #title>
          <span>
            <ShoppingOutlined />
            <span>店铺</span>
          </span>
        </template>
        <a-menu-item key="25" @click="changeRouter('/store')"
          ><BarsOutlined /><span>店铺管理</span></a-menu-item
        >
      </a-sub-menu>
      <a-sub-menu key="sub3">
        <template #title>
          <span>
            <ShoppingOutlined />
            <span>商品</span>
          </span>
        </template>
        <a-menu-item v-if="!admin" key="5" @click="changeRouter('/goods')"
          ><BarsOutlined /><span>店铺商品</span></a-menu-item
        >
        <a-menu-item v-if="admin" key="26" @click="changeRouter('/allgoods')"
          ><BarsOutlined /><span>商品管理</span></a-menu-item
        >
        <a-menu-item v-if="admin" key="7" @click="changeRouter('/category')"
          ><ShopOutlined /><span>商品分类</span></a-menu-item
        >
        <a-menu-item v-if="admin" key="8" @click="changeRouter('/brand')"
          ><AppstoreAddOutlined /><span>品牌管理</span></a-menu-item
        >
      </a-sub-menu>
      <a-sub-menu v-if="!admin" key="sub4">
        <template #title>
          <span>
            <ShoppingCartOutlined />
            <span>订单</span>
          </span>
        </template>
        <a-menu-item @click="changeRouter('/order')" key="9"
          ><BarsOutlined /><span>订单管理</span></a-menu-item
        >
        <a-menu-item key="11" @click="notify"
          ><ForkOutlined /><span>退货处理</span></a-menu-item
        >
        <a-menu-item key="12" @click="notify"
          ><FileDoneOutlined /><span>退货原因</span></a-menu-item
        >
      </a-sub-menu>
      <!-- <a-sub-menu v-if="!admin" key="sub5">
        <template #title>
          <span>
            <ApartmentOutlined />
            <span>营销</span>
          </span>
        </template>
        <a-menu-item key="13"
          ><BarsOutlined /><span>秒杀管理</span></a-menu-item
        >
        <a-menu-item key="14"
          ><ForkOutlined /><span>优惠券管理</span></a-menu-item
        >
        <a-menu-item key="15"
          ><MacCommandOutlined /><span>品牌推荐</span></a-menu-item
        >
        <a-menu-item key="16"
          ><LayoutOutlined /><span>新品推荐</span></a-menu-item
        >
        <a-menu-item key="17"
          ><HourglassOutlined /><span>人气推荐</span></a-menu-item
        >
        <a-menu-item key="18"
          ><BlockOutlined /><span>专题推荐</span>
        </a-menu-item>
        <a-menu-item key="19"
          ><BarsOutlined /><span>广告管理</span></a-menu-item
        >
      </a-sub-menu> -->
      <a-sub-menu v-if="admin" key="sub6">
        <template #title>
          <span>
            <SettingOutlined />
            <span>系统</span>
          </span>
        </template>
        <a-menu-item v-if="admin" key="20" @click="changeRouter('/notice')"
          ><BarsOutlined /><span>公告管理</span></a-menu-item
        >
        <a-menu-item v-if="admin" key="22" @click="changeRouter('/feedback')"
          ><MacCommandOutlined /><span>反馈管理</span></a-menu-item
        >
        <a-menu-item v-if="admin" key="30" @click="changeRouter('/oper')"
          ><ToolOutlined /><span>系统操作</span></a-menu-item
        >
        <a-menu-item v-if="admin" key="31" @click="changeRouter('/exception')"
          ><BugOutlined /><span>系统异常</span></a-menu-item
        >
      </a-sub-menu>
      <a-sub-menu v-if="!admin" key="sub7">
        <template #title>
          <span>
            <CommentOutlined />
            <span>评论</span>
          </span>
        </template>
        <a-menu-item key="40" @click="changeRouter('/storecomment')"
          ><ShoppingOutlined /><span>店铺评论</span></a-menu-item
        >
        <a-menu-item key="41" @click="changeRouter('/goodscomment')"
          ><ShopOutlined /><span>商品评论</span></a-menu-item
        >
      </a-sub-menu>
    </a-menu>
  </a-layout-sider>
</template>
<script setup>
import { ref } from "vue";
import {
  UserAddOutlined,
  ToolOutlined,
  BugOutlined,
  UsergroupAddOutlined,
  DashboardOutlined,
  ApartmentOutlined,
  UserOutlined,
  ShoppingOutlined,
  HourglassOutlined,
  BarsOutlined,
  ShopOutlined,
  AppstoreAddOutlined,
  ShoppingCartOutlined,
  SettingOutlined,
  FileDoneOutlined,
  ForkOutlined,
  MacCommandOutlined,
  LayoutOutlined,
  BlockOutlined,
  EyeOutlined,
  DesktopOutlined,
  CommentOutlined,
} from "@ant-design/icons-vue";
import router from "@/router";
import { useAdminStore } from "@/stores/admin";
import { message } from "ant-design-vue";

const collapsed = ref(false);
const selectedKeys = ref(["1"]);
//权限控制
const adminStore = useAdminStore();
const admin = ref(false);
if (adminStore.admin.role === "管理员") {
  admin.value = true;
}

//页面跳转
function changeRouter(path) {
  router.push(path);
}

function notify() {
  message.warning("待开发功能，敬请期待");
}
</script>
<style scoped>
.site-layout .site-layout-background {
  background: #fff;
}
[data-theme="dark"] .site-layout .site-layout-background {
  background: #141414;
}
</style>